﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AimGameLibrary.GameObject
{

    public class GameInt : GameBaseValue
    {
        int myint;
        public int MyinT { get { myint = (int)GetParentValue(); return myint; } set { myint = value; SetParentValue(myint); } }

        public override void LoadData(Identification getdata, int IndexData, NodeData node)
        {
            InputMode = (NodeInputMode)getdata.Items.GetValue(IndexData + 1);
            if (InputMode == NodeInputMode.Int_1)
                Listnameparent.Add(node.Data);
            else MyinT = (int)getdata.Items.GetValue(IndexData + 2);
        }

        protected override object GetParentValue()
        {
            if(this.Listparent.Count > 0)
            {
                if (InputMode == NodeInputMode.Int_1
                    && Listparent[0].GetType() == typeof(GameInt))
                {
                    GameInt tempparent = (GameInt)Listparent[0];
                    return tempparent.MyinT;
                }
                else return myint;
            }else return myint;
        }

        protected override void SetParentValue(object obj)
        {
            if (this.Listparent.Count > 0)
            {
                if(InputMode == NodeInputMode.Int_1)
                    if (Listparent[0].GetType() == typeof(GameInt))
                    {
                        GameInt tempparent = (GameInt)Listparent[0];
                        tempparent.MyinT = (int)obj;
                    }
            } 
        }
    }
}
